﻿using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;

namespace CADTool
{
    public class JigDBText : DrawJig
    {
        public DBText txt;
        public Point3d p0;
        public JigDBText(DBText txt, Point3d p0)
        {
            this.txt = txt;
            this.p0 = p0;
        }
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            PromptPointResult psr = prompts.AcquirePoint();
            if (psr.Status == PromptStatus.OK)
            {
                Point3d temp = psr.Value;
                if (temp != p0)
                {
                    p0 = temp;
                    txt.Position = p0;
                    if (txt.Height==0)
                    {
                        txt.Height = 10;
                    }                  
                    return SamplerStatus.OK;
                }
            }
            return SamplerStatus.NoChange;
        }

        protected override bool WorldDraw(WorldDraw draw)
        {
            draw.Geometry.Draw(txt);
            return true;
        }
    }
}
